// app.js
import { request } from './common/request';

App({
  onLaunch() {
    //登录
    const getCode = () => {
      return new Promise(function (reslove) {
        wx.login({
          success(res) {
            wx.setStorageSync('code', res.code);
            reslove(res.code);
          },
        });
      });
    };
    const wxLogin = async () => {
      const code = await getCode();
      const wxRes = await request({
        url: '/auth/wx',
        method: 'POST',
        data: {
          code,
        },
      });
      console.log('🚀 ~ file: app.js:26 ~ wxLogin ~ wxRes:', wxRes);
    };
    wxLogin();
  },
  globalData: {
    userInfo: null,
  },
});
